package com.lagou.listener;

import com.lagou.boot.ClientBootStrap;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;

/**
 * @author
 */
public class ChildrenListener implements PathChildrenCacheListener {

    @Override
    public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception {
        switch (pathChildrenCacheEvent.getType()){
            case CHILD_ADDED:
                ClientBootStrap.addRpcConsumer(pathChildrenCacheEvent.getData().getData());
                break;
            case CHILD_REMOVED:
                ClientBootStrap.removeRpcConsumer(pathChildrenCacheEvent.getData().getData());
                break;
            default:;
        }
    }
}
